/**
 * @(#)Banque.java
 *
 *
 * @author quentin jeremy mathieu
 * @version 1.00 2012/5/11
 */
import java.util.HashMap;
import java.util.LinkedList;

public class Banque 
{

private HashMap<Ressource,Integer> sacRessource;
private LinkedList<Commande> sacCommande;

// Constructeur 
public Banque () 
{
	sacRessource = new HashMap<Ressource,Integer>();
	sacRessource.put(Ressource.sel, 18);
	sacRessource.put(Ressource.orge, 15);
	sacRessource.put(Ressource.the, 12);
	sacRessource.put(Ressource.jade, 9 );
	sacRessource.put(Ressource.or, 6);	
	
	sacCommande = new LinkedList<Commande>();
	sacCommande.add(new Commande());	
}
// methode toString
public String toString () 
{	
	return "sacRessource : " + sacRessource.toString() +"\n" + "sacCommande : " + 
			sacCommande.toString();
} 
//Accesseur

public int getSel(){ return sacRessource.get(Ressource.sel);}
public int getOrge(){ return sacRessource.get(Ressource.orge);}
public int getThe(){return sacRessource.get(Ressource.the);}
public int getJade(){return sacRessource.get(Ressource.jade);}
public int getOr(){return sacRessource.get(Ressource.or);}

// viderRessource
public void viderRessource(Ressource ressourceP)
{
	int x = 0;
	x = this.sacRessource.get(ressourceP) - 1;
	this.sacRessource.put(ressourceP, x);										
}	
// remplirRessource
public void remplirRessource(Ressource ressourceP)
{
	int x = 0;
	x = this.sacRessource.get(ressourceP) + 1;
	this.sacRessource.put(ressourceP, x);	
}
//viserCommande
public void viderCommande(Commande commandeP){this.sacCommande.remove(commandeP);}
//ajoutCommande
public void ajoutCommande (Commande commandeP){this.sacCommande.add(commandeP);}

// equals
public Boolean equals (Banque b2)
{
	//test sacRessource
	if( this.sacRessource.size() != b2.sacRessource.size()) return false;
	//test sacCommande
	if( this.sacCommande.size() != b2.sacCommande.size()) return false;
	
	// test de sac ressource
	for (int i =0; i < this.sacRessource.size() ;i++)
	{
		if (this.sacRessource.get(i) != b2.sacRessource.get(i)) return false;
	}
	
	for (int j =0; j < this.sacCommande.size() ;j++)
	{
		if (!(this.sacCommande.get(j).equals(b2.sacCommande.get(j))) ) return false;
	}

	return true ;
}
protected Object clone()
{
	Banque b2 = new Banque();
	
	for (int i  = 0; i < this.sacRessource.size() ; i++)
	{
		
	}
	
	return (Banque)b2;
}

}